﻿<!DOCTYPE html>
<html>
<head>
    <title>Freemium Applications Helper for WebMatrix - Start Here</title>
    <link href="content/Site.css" rel="stylesheet" type="text/css" />
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
</head>
<body>
    <div class="container">
        <div class="header">
            <img src="content/images/webx-icon.png" alt="WebMatrix" />
            <h1>
                WebMatrix Helpers</h1>
            <h2>
                Freemium Applications Helper - Start Here</h2>
        </div>
        <div class="content">
			<div class="navLinks">
				<a href="startHere.htm">Start Here</a> | <a href="reference.htm">Helper Reference</a>
			</div>
            <h3>
                Introduction</h3>
            <p>
                Microsoft WebMatrix provides an easy way to get started with web development, and
                together with new Razor syntax for ASP.NET Web Pages it includes everything you
                need to get your web site up, running and integrated with many other sites and networks,
                in a short period of time. The WebMatrix helpers are designed to make your life
                easier when creating web sites. They provide you a simple and consistent way of
                performing common web development tasks that otherwise would require a great deal
                of custom coding. With a few lines of code you should be able to secure your web
                site using membership, store information in Windows Azure Storage, integrate your
                site with Facebook, among others things.
            </p>
            <p>
                When offering services via a web site, a popular way to attract first time users
                is to offer a free version of the software that has limited functionality. A good
                way to convert that non-paying customer into a paying customer is to offer more
                functionality and features beyond what is available in the free version and allow
                the transition between versions to be seamless. This business model of delivering
                “basic services for free, while charging a premium for advanced or special features”
                is known as the <strong>Freemium business model</strong>.
            </p>
            <p>
                The <strong>Freemium Applications Helper</strong> for WebMatrix provides an easy
                way to apply the Freemium model into your WebMatrix site. Using different user groups
                (or roles), it allows you to easily enable or disable features on your pages depending
                on the stock-keeping unit the user has paid for. It also provides an easy way to
                administrate the Freemium model using a stock-keeping unit/features matrix to manage
                which features are available in each SKUs.
            </p>
            <img src="content/images/freemium-helper.png" height="250" class="centeredImage" />
            <div>
                <i>Note: Stock-Keeping Units are the way to identify the different versions of the products
                    you’re offering through your Web application. Each SKU has an associated set of
                    features, only available for those users who have purchased the SKU.</i></div>
            <h3>
                Getting Started in 60 Seconds</h3>
            <p>
                The helper includes the following files:</p>
            <ul>
                <li>The <strong>Freemium.cs</strong> file located into the <strong>App_Code</strong>
                    folder of your WebMatrix site.</li>
                <li>A <strong>Freemium</strong> folder, which includes all the Freemium model administration
                    pages to create and edit stock-keeping units and features. Notice these pages are
                    prepared to be used with a layout page, as explained <a href="http://www.asp.net/webmatrix/tutorials/3-creating-a-consistent-look">
                    in this WebMatrix tutorial</a>. And also they are prepared so that only users
                    on the &quot;admin&quot; user group have permissions to enter these pages.</li>               
            </ul>
            <p>
                To use the Freemium Helper follow these steps:</p>
            <ol>
                <li>This helper requires that you setup web site membership with the <strong>WebSecurity</strong>
                    WebMatrix helper, as explained <a href="http://www.asp.net/webmatrix/tutorials/16-adding-security-and-membership">
                        in this WebMatrix tutorial</a>. Make sure the registration page is only accessible
                    to the site administrator.</li>
                <li>Optionally, you can have pages in your site for administrating user accounts and
                    user groups (or roles) to avoid editing your database manually. You can take a look
                    at an example for these pages in the <strong>Freemium Sample</strong> (see below).</li>
                <li>Add the following line to the <strong>_AppStart.cshtml</strong> page of your WebMatrix site,
                    replacing the <i>"your-database-name"</i> placeholder, with your web site database
                    name. This helper requires that you create a database for your web site. You can
                    find instructions on how to do this <a href="http://www.asp.net/webmatrix/tutorials/5-working-with-data">
                        in this WebMatrix tutorial</a>.
                    <pre class="code">
@{
    <span class="highlight">Freemium.Initialize(&quot;your-database-name&quot;, createBaseDataSet: true);</span>
}</pre>
                    The second parameter in <strong>true</strong> indicates that a base set of stock-keeping
                    units and features will be created automatically in this database. </li>
                <li>Add the following lines to display the SKU/Features matrix in a page:
                    <pre class="code">
@Freemium.GetFeatureByStockKeepingUnitMatrixHtml()</pre>
                </li>
                <li>Create a new user in your Web site and then create two new user groups (or roles):
                    &quot;silver&quot; and &quot;gold&quot;. Put the new user into the &quot;gold&quot;
                    role. You can do this manually, by editing the <em>webpages_Roles</em> and <em>webpages_UsersInRoles</em>
                    tables from your database as explained <a href="http://www.asp.net/webmatrix/tutorials/16-adding-security-and-membership">
                        in this WebMatrix tutorial</a>.</li>
                <li>Add the highlighted lines from below in the page where you want to disable some
                    feature for free users, for example &quot;feature 3&quot;, which is only enabled
                    for &quot;gold&quot; users.
                    <pre class="code">
&lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;body&gt;
        ...
        <span class="highlight">@if(Freemium.IsFeatureEnabledForCurrentUser(&quot;feature3&quot;))&nbsp;{</span>
          &lt;p&gt;This text will only be displayed for users in the &quot;gold&quot; stock-keeping unit.&lt;/p&gt;
        <span class="highlight">}</span>
    &lt;/body&gt;
&lt;/html&gt;</pre>
                </li>
                <li>Test how the disabled feature, &quot;feature 3&quot; is only enabled for the users
                    in the &quot;gold&quot; group (or role) you've created (that is, users who have
                    purchased the <em>gold</em> stock-keeping unit).</li>
            </ol>
            <h3>
                Running the Freemium Sample</h3>
            <p>
                Optionally, you can download a sample WebMatrix web site where you can see the helper
                in action and also get examples of pages for managing users and groups of your Freemium model. 
                To download and run it with Microsoft WebMatrix, follow these steps:</p>
            <ol>
                <li>Download the sample site from the helper's <a href="http://freemiumhelper.codeplex.com/">Codeplex</a> site, Downloads section. Extract the contents and open the folder in WebMatrix.</li>
                <li>Click the <strong>Run</strong> button to open the sample.</li>
                <li>Browse to the Login page, enter the administrator password as shown there and then
                    browse to the <strong>Manage Site</strong> page.</li>
                <li>In the <strong>Role Management</strong> section, see the associated stock-keeping
                    unit for each role.</li>
                <li>Click <strong>Freemium Admin</strong> and play with the Freemium Model!</li>
            </ol>
            <h3>
                More Info</h3>
				
			<p>
                Don't miss the helper's <a href="http://www.youtube.com/watch?v=z0JuSg6j_BM">getting started screencast</a>.
            </p>
            <p>
                You can find more information about the Freemium Business Model in <a href="http://www.freemium.org/">
                    freemium.org</a></p>
            <p>
                Learn more on WebMatrix, ASP.NET Web Pages and the Razor Syntax <a href="http://www.microsoft.com/web/webmatrix/learn/">
                    with the WebMatrix tutorials</a>.
            </p>
            <p>
                To explore the helper's implementation you can open the <strong>Freemium.cs</strong>
                file located under the <strong>App_code</strong> folder.
                Additionally, you can get more information on the
                helper from the <a href="http://freemiumhelper.codeplex.com/">Freemium Helper CodePlex project</a>.                                
            </p>
        </div>
        <ul class="footer">
            <li>We're always looking for <a href="mailto:webapp@microsoft.com">bugs, feedback and
                suggestions!</a></li>
            <li>&copy; 2010-2011 Microsoft Corporation. Powered by IIS Express.</li>
        </ul>
    </div>
</body>
</html>